#include "VAnimatedPictures.h"

VAnimatedPictures::VAnimatedPictures()
{
    this->setFixedWidth(265);
    this->image = new QPixmap;
    this->collection = new QList<QString>;
    this->collection->append("fourmi.png");
    this->collection->append("coucou.png");
    this->collection->append("desir.png");
    this->collection->append("starfighter.png");

    this->it = this->collection->begin();

    this->label = new QLabel("haha");

    this->layoutp = new QVBoxLayout;
    this->layoutp->addWidget(this->label);

    this->setLayout(this->layoutp);

    this->image->load("fourmi.png");
    this->label->setPixmap(*this->image);

    this->timer = new QTimer;

    QObject::connect(this->timer, SIGNAL(timeout()), this, SLOT(next_picture()));
    this->timer->start(3000);
}

VAnimatedPictures::~VAnimatedPictures()
{
    delete this->image;
    delete this->collection;
    delete this->label;

    delete this->layoutp;
    delete this->timer;
}


void VAnimatedPictures::next_picture()
{
    this->it++;
    if(this->it == this->collection->end())
        this->it = this->collection->begin();

    this->image->load(*this->it.operator ->());
    this->label->setPixmap(*this->image);
}
